package o;

import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import o.fui.a;

public final class fvr {
    private static final fxh ˋ = fxh.ˏ("\t ,=");
    private static final fxh ˏ = fxh.ˏ("\"\\");

    public static long ˏ(fvb o_fvb) {
        return ˊ(o_fvb.ʼ());
    }

    public static long ˊ(fui o_fui) {
        return ˊ(o_fui.ॱ("Content-Length"));
    }

    private static long ˊ(String str) {
        long j = -1;
        if (str != null) {
            try {
                j = Long.parseLong(str);
            } catch (NumberFormatException e) {
            }
        }
        return j;
    }

    public static boolean ˏ(fvb o_fvb, fui o_fui, fus o_fus) {
        for (String str : ˋ(o_fvb)) {
            if (!fvg.ॱ(o_fui.ˎ(str), o_fus.ˏ(str))) {
                return false;
            }
        }
        return true;
    }

    public static boolean ॱ(fvb o_fvb) {
        return ॱ(o_fvb.ʼ());
    }

    public static boolean ॱ(fui o_fui) {
        return ˋ(o_fui).contains("*");
    }

    private static Set<String> ˋ(fvb o_fvb) {
        return ˋ(o_fvb.ʼ());
    }

    public static Set<String> ˋ(fui o_fui) {
        Set<String> emptySet = Collections.emptySet();
        int ˋ = o_fui.ˋ();
        for (int i = 0; i < ˋ; i++) {
            if ("Vary".equalsIgnoreCase(o_fui.ॱ(i))) {
                String ˋ2 = o_fui.ˋ(i);
                if (emptySet.isEmpty()) {
                    emptySet = new TreeSet(String.CASE_INSENSITIVE_ORDER);
                }
                for (String trim : ˋ2.split(",")) {
                    emptySet.add(trim.trim());
                }
            }
        }
        return emptySet;
    }

    public static fui ˎ(fvb o_fvb) {
        return ॱ(o_fvb.ॱॱ().ॱ().ॱ(), o_fvb.ʼ());
    }

    public static fui ॱ(fui o_fui, fui o_fui2) {
        Set ˋ = ˋ(o_fui2);
        if (ˋ.isEmpty()) {
            return new a().ˊ();
        }
        a aVar = new a();
        int ˋ2 = o_fui.ˋ();
        for (int i = 0; i < ˋ2; i++) {
            String ॱ = o_fui.ॱ(i);
            if (ˋ.contains(ॱ)) {
                aVar.ˊ(ॱ, o_fui.ˋ(i));
            }
        }
        return aVar.ˊ();
    }

    public static void ॱ(fue o_fue, fur o_fur, fui o_fui) {
        if (o_fue != fue.ॱ) {
            List ˋ = fug.ˋ(o_fur, o_fui);
            if (!ˋ.isEmpty()) {
                o_fue.ॱ(o_fur, ˋ);
            }
        }
    }

    public static boolean ˊ(fvb o_fvb) {
        if (o_fvb.ॱ().ˋ().equals("HEAD")) {
            return false;
        }
        int ˊ = o_fvb.ˊ();
        if ((ˊ < 100 || ˊ >= 200) && ˊ != 204 && ˊ != 304) {
            return true;
        }
        if (ˏ(o_fvb) != -1 || "chunked".equalsIgnoreCase(o_fvb.ˋ("Transfer-Encoding"))) {
            return true;
        }
        return false;
    }

    public static int ˎ(String str, int i, String str2) {
        while (i < str.length() && str2.indexOf(str.charAt(i)) == -1) {
            i++;
        }
        return i;
    }

    public static int ˎ(String str, int i) {
        while (i < str.length()) {
            char charAt = str.charAt(i);
            if (charAt != ' ' && charAt != '\t') {
                break;
            }
            i++;
        }
        return i;
    }

    public static int ˏ(String str, int i) {
        try {
            long parseLong = Long.parseLong(str);
            if (parseLong > 2147483647L) {
                return ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED;
            }
            if (parseLong < 0) {
                return 0;
            }
            return (int) parseLong;
        } catch (NumberFormatException e) {
            return i;
        }
    }
}
